package com.example.badminton.controller;

import com.example.badminton.common.AnonymousAccess;
import com.example.badminton.common.Result;
import com.example.badminton.entity.CourtType;
import com.example.badminton.service.CourtTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/courtType")
@CrossOrigin
public class CourtTypeController {

    @Autowired
    private CourtTypeService courtTypeService;

    @AnonymousAccess
    @GetMapping("/list")
    public Result<List<CourtType>> getCourtTypeList() {
        List<CourtType> list = courtTypeService.lambdaQuery()
                .eq(CourtType::getStatus, 1)
                .orderByAsc(CourtType::getId)
                .list();
        return Result.success(list);
    }
}